package pers.kw.config.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import java.util.List;

@RefreshScope
@Component
@ConfigurationProperties(prefix = "oauth-config")
public class OAuthConfigProperties {

    private ClientInfo clientInfo;

    private OAuthToken oauthToken;

    public static class ClientInfo {
        private String clientId;
        private String clientSecret;
        private List<String> authorizedGrantTypes;
        private List<String> scopes;

        public String getClientId() {
            return clientId;
        }

        public void setClientId(String clientId) {
            this.clientId = clientId;
        }

        public String getClientSecret() {
            return clientSecret;
        }

        public void setClientSecret(String clientSecret) {
            this.clientSecret = clientSecret;
        }

        public List<String> getAuthorizedGrantTypes() {
            return authorizedGrantTypes;
        }

        public void setAuthorizedGrantTypes(List<String> authorizedGrantTypes) {
            this.authorizedGrantTypes = authorizedGrantTypes;
        }

        public List<String> getScopes() {
            return scopes;
        }

        public void setScopes(List<String> scopes) {
            this.scopes = scopes;
        }
    }

    public static class OAuthToken {
        /**
         * accessToken有效期
         */
        private int accessTokenValiditySeconds;

        /**
         * refreshToken有效期
         */
        private int refreshTokenValiditySeconds;

        /**
         * 加签秘钥
         */
        private String signingKey;

        /**
         * 验签秘钥
         */
        private String verifierKey;

        public int getAccessTokenValiditySeconds() {
            return accessTokenValiditySeconds;
        }

        public void setAccessTokenValiditySeconds(int accessTokenValiditySeconds) {
            this.accessTokenValiditySeconds = accessTokenValiditySeconds;
        }

        public int getRefreshTokenValiditySeconds() {
            return refreshTokenValiditySeconds;
        }

        public void setRefreshTokenValiditySeconds(int refreshTokenValiditySeconds) {
            this.refreshTokenValiditySeconds = refreshTokenValiditySeconds;
        }

        public String getSigningKey() {
            return signingKey;
        }

        public void setSigningKey(String signingKey) {
            this.signingKey = signingKey;
        }

        public String getVerifierKey() {
            return verifierKey;
        }

        public void setVerifierKey(String verifierKey) {
            this.verifierKey = verifierKey;
        }
    }

    public ClientInfo getClientInfo() {
        return clientInfo;
    }

    public void setClientInfo(ClientInfo clientInfo) {
        this.clientInfo = clientInfo;
    }

    public OAuthToken getOauthToken() {
        return oauthToken;
    }

    public void setOauthToken(OAuthToken oauthToken) {
        this.oauthToken = oauthToken;
    }
}
